package com.bjsxt.userscenter.head.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.bjsxt.userscenter.common.controller.BaseController;
import com.bjsxt.userscenter.common.util.ConstatFinalUtil;

/**
 * 用户登陆后的Controller
 * 
 * @author haihai
 *
 */
@Controller
@RequestMapping("/head/users")
public class UsersHeadController extends BaseController
{
	/**
	 * 登陆后的首页
	 * @return
	 */
	@RequestMapping("/main")
	public String main()
	{
		ConstatFinalUtil.LOGGER.info("--- main ---");
		return "/head/users/main";
	}
	/**
	 * 退出登录
	 * @param request
	 * @param session
	 * @return
	 */
	@RequestMapping("/loginout")
	public String loginout(HttpServletRequest request, HttpSession session)
	{
		ConstatFinalUtil.LOGGER.info("----loginout----");
		/* 将session中的信息删除 */
		session.removeAttribute("users");
		session.removeAttribute("lastLoginTime");
		/* 操作Token */
		String token=request.getParameter("token");
		if(token ==null)
		{
			token="";
		}
		if(!"".equalsIgnoreCase(token))
		{
			ConstatFinalUtil.TOKENS_MAP.remove(token);
		}
		this.info=ConstatFinalUtil.INFO_JSON.getString("8");
		session.setAttribute("info", info);
		return "redirect:/login.htm" ; 
		
	}
}
